<?php  
	require_once('functions.php');

	if(!isset($_SESSION['isLogged'])) {
		header('Location: index.php');
		exit;
	}
	if(isset($_POST['traktors'])) {

		$id_list = implode(',', $_POST['traktors']);
		$deletionQuery = "DELETE FROM traktor WHERE traktor_id in ($id_list)";
		$deleteFileQuery = "SELECT image FROM traktor where traktor_id in ($id_list)";
		$result = mysqli_query($db, $deleteFileQuery);
		unlink();

		if(mysqli_query($db, $deletionQuery)) {
			while($row = $result->fetch_assoc()) {
				unlink($row['image']);
			}
			header('Location: index.php');
			exit;
		} else {
			echo "<p>deleting error</p>";
		}

	} else {
		echo "please select traktors";
		echo "<a href=\"index.php\">Go Back</a>";
	}
